package org.dxy.infrastructure.adapter.repository;

import lombok.RequiredArgsConstructor;
import org.dxy.domain.port.repository.IEquipmentRepository;
import org.dxy.domain.model.aggregate.Equipment;
import org.dxy.infrastructure.persistent.po.EquipmentPo;
import org.dxy.infrastructure.persistent.service.EquipmentService;
import org.springframework.stereotype.Repository;

/**
 * @description:
 * @author: Administrator
 * @createTime: 2025/5/6 23:56
 */
@Repository
@RequiredArgsConstructor
public class EquipmentRepository implements IEquipmentRepository {

    private final EquipmentService equipmentService;
    @Override
    public Equipment findById(Long equipmentId) {
        return null;
    }

    @Override
    public boolean save(Equipment equipment) {
        EquipmentPo equipmentPo = new EquipmentPo();

        // 领域模型的 EquipmentId 转为 Long
        equipmentPo.setEquipmentId(equipment.getEquipmentId().getValue());
        equipmentPo.setStatus(equipment.getStatus().getKey());
        equipmentPo.setCurrentWorkOrderId(equipment.getCurrentWorkOrderId());
        equipmentPo.setCurrentProcessStepId(equipment.getCurrentProcessStepId());
        return equipmentService.save(equipmentPo);
    }

    @Override
    public boolean existsById(Long equipmentId) {
        return false;
    }

    @Override
    public boolean delete(Equipment equipment) {
        return false;
    }

    @Override
    public boolean existsBySerialNumber(String serialNumber) {
        return false;
    }
}
